package com.controller;

import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;







import com.mysql.fabric.Response;
import com.pojo.Users;
import com.service.fileService;
import com.service.logService;
import com.service.usersService;




@Controller
public class UsersControler {
	usersService a=new usersService();
	logService b=new logService();
	fileService c=new fileService();
	
	@RequestMapping(value = "/query_login.action", method = RequestMethod.POST)
	@ResponseBody
	public String query_login(
			@RequestParam(value = "account", defaultValue = "") String account,
			@RequestParam(value = "password", defaultValue = "") String password,
			HttpServletResponse response
			) {
		Users result=a.query_login(account, password);
		if("0".equals(result.getCounter())){
			return "ERR";
		}
		response.addCookie(new Cookie("result", result.getId().toString()));
		System.out.println(password);
		b.add2(result.getId(), "登陆");
		return "OK";
	}
	

	
}